<?php
class Room
{
	var $roomID = "";
	var $roomName = "";
	var $maxUserNum = 200;
	var $userList = array();//存放的是对应user的socketID
	var $tableList = array();
	//返回服务器选择时的信息
	function __toString()
	{
		return '{"roomID":"'.$this->roomID.'","roomName":"'.$this->roomName.'","maxUserNum":"'.$this->maxUserNum.'","userNum":"'.count($this->userList).'"}';
	}

	//返回没有进入游戏桌的玩家
	function getFreeUser()
	{
		$uc = UserCenter::getInstance()->userList;
		$rl=array();
		foreach($this->userList as $u)
		{
			if(empty($uc[$u]->tableID))
			{
				array_push($rl,$u);
			}
		}
		return $rl;
	}

	function getTableList()
	{

	}

	function enterRoom($ip)
	{
		UserCenter::getInstance()->userList[$ip]->enterRoom($this->roomID);
		$this->userList[$ip]=$ip;
	}
	function leaveRoom($ip)
	{

	}

	function createTable($table)
	{
		$this->tableList[$table->tableID] = $table;
	}

	function deleteTable($tableID)
	{
		unset($this->tableList[$tableID]);
	}
}//end of class Room